package com.js.purs.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.js.purs.domain.PurAppRecords;
import com.js.purs.service.IPurAppRecordsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 审批计划Controller
 * 
 * @author lzq
 * @date 20240625
 */
@RestController
@RequestMapping("/records")
public class PurAppRecordsController extends BaseController
{
    @Autowired
    private IPurAppRecordsService purAppRecordsService;

    /**
     * 查询审批计划列表
     */
    @RequiresPermissions("purs:records:list")
    @GetMapping("/list")
    public TableDataInfo list(PurAppRecords purAppRecords)
    {
        startPage();
        List<PurAppRecords> list = purAppRecordsService.selectPurAppRecordsList(purAppRecords);
        return getDataTable(list);
    }

    /**
     * 导出审批计划列表
     */
    @RequiresPermissions("purs:records:export")
    @Log(title = "审批计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurAppRecords purAppRecords)
    {
        List<PurAppRecords> list = purAppRecordsService.selectPurAppRecordsList(purAppRecords);
        ExcelUtil<PurAppRecords> util = new ExcelUtil<PurAppRecords>(PurAppRecords.class);
        util.exportExcel(response, list, "审批计划数据");
    }

    /**
     * 获取审批计划详细信息
     */
    @RequiresPermissions("purs:records:query")
    @GetMapping(value = "/{flowId}")
    public AjaxResult getInfo(@PathVariable("flowId") Long flowId)
    {
        return success(purAppRecordsService.selectPurAppRecordsByFlowId(flowId));
    }

    /**
     * 新增审批计划
     */
    @RequiresPermissions("purs:records:add")
    @Log(title = "审批计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurAppRecords purAppRecords)
    {
        return toAjax(purAppRecordsService.insertPurAppRecords(purAppRecords));
    }

    /**
     * 修改审批计划
     */
    @RequiresPermissions("purs:records:edit")
    @Log(title = "审批计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurAppRecords purAppRecords)
    {
        return toAjax(purAppRecordsService.updatePurAppRecords(purAppRecords));
    }

    /**
     * 删除审批计划
     */
    @RequiresPermissions("purs:records:remove")
    @Log(title = "审批计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flowIds}")
    public AjaxResult remove(@PathVariable Long[] flowIds)
    {
        return toAjax(purAppRecordsService.deletePurAppRecordsByFlowIds(flowIds));
    }


}
